import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

class Student{

}
public class Test {
    public static void main(String[] args) {
        String[] strings={"this","ha","man","this","haha","ha","sor"};
        calcWordCount(strings);

    }
    public static void main1(String[] args) {
        HashBuck<Integer, Integer> hashBuck=new HashBuck<>();
        hashBuck.put(1,1);
        hashBuck.put(2,1);
        hashBuck.put(3,1);
        hashBuck.put(4,1);
        hashBuck.put(14,1);
        hashBuck.put(24,1);
        hashBuck.put(7,1);
        hashBuck.put(8,1);
        Map<Student,Integer> map=new HashMap<>();
        map.put(new Student(),1);
        map.put(new Student(),2);
        int[] arr=new int[]{1,23,4,43,2,34,234,3,2,1,4};
        System.out.println(findFirst(arr));
        System.out.println(update(arr));
    }
    public static Integer findFirst(int[] arr){
        Set<Integer> set=new HashSet<>();
        for (int i = 0; i <arr.length ; i++) {
            if(set.contains(arr[i])){
                return arr[i];
            }
            set.add(arr[i]);
        }
        return null;
    }
    public static  Set<Integer> update(int[] arr){
        Set<Integer> set=new HashSet<>();
        for (int i = 0; i <arr.length ; i++) {

            set.add(arr[i]);
        }
        return set;
    }
    public static void calcWordCount(String[] strings){
        Map<String,Integer> map=new HashMap<>();
        for (int i = 0; i <strings.length ; i++) {
            if(map.containsKey(strings[i])){
                int oldVal=map.get(strings[i]);
                map.put(strings[i],oldVal+1 );
            }else{
                map.put(strings[i],1);
            }
        }
        Set<Map.Entry<String,Integer>> set=map.entrySet();
        for (Map.Entry<String,Integer> entry:set
             ) {
            System.out.println("单词："+entry.getKey()+" 出现了"+entry.getValue() + "  次数");
        }
    }
}
